﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ATCAssistant.Properties;

namespace ATCAssistant
{
    public partial class AddToolDialog : Form
    {
        public AddToolDialog()
        {
            InitializeComponent();
        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.txtPath.Clear();
            this.txtTitle.Clear();
            this.DialogResult = DialogResult.Cancel;
        }

        private void cmdOk_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtPath.Text))
            {
                MessageBox.Show("Please enter a path to the executable.");
                return;
            }

            if (String.IsNullOrEmpty(txtTitle.Text))
            {
                MessageBox.Show("Please enter a title for this tool.");
                return;
            }

            // add the new tool
            Settings.Default.ExternalTools.Add(txtPath.Text, txtTitle.Text);

            // report success
            this.DialogResult = DialogResult.OK;
        }

        private void cmdBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                txtPath.Text = dlg.FileName;
            }
        }
    }
}
